package bavaria.hightech.testit;


import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

import bavaria.hightech.money.Currency;
import bavaria.hightech.money.Money;

public class MoneyTest {
	
	private Money m1; 
	private Money m2;
	private Money m3;
	private Money m4;
	private Money m5;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}


	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		
	this.m1 = new Money(1200, Currency.EURO);	
	this.m2 = new Money(600, Currency.EURO);
	this.m3 = new Money(500, Currency.EURO);
	this.m4 = new Money(1200, Currency.EURO);
	this.m5 = new Money(1200,Currency.EURO);
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testGetValue(){
		assertTrue(m2.equals(m2));
		assertTrue(m3.equals(m3));
		assertTrue(m2.equals(m2));
		assertTrue(m3.equals(m3));
		assertTrue(m2.equals(m2));
		assertTrue(m3.equals(m3));
		assertTrue(m2.equals(m2));
		assertFalse(m3.equals(m4));
//		assertFalse(m1.equals(m4));
		assertFalse(m3.equals(m4));
		assertFalse(m3.equals(m2));
		assertFalse(m2.equals(m3));
		assertTrue(m2.equals(m2));
		assertTrue(m3.equals(m3));
		assertTrue(m2.equals(m2));
		assertTrue(m3.equals(m3));
		assertTrue(m2.equals(m2));
		assertTrue(m3.equals(m3));
		assertTrue(m2.equals(m2));
	}
	
	@Test
	public void testAdd(){
		assertTrue(((m1.addMoney(m2)).equals(new Money(1800, Currency.EURO))));
		assertTrue(((m2.addMoney(m2)).equals(new Money(1200, Currency.EURO))));
		assertTrue(((m1.addMoney(m2)).equals(new Money(3000, Currency.EURO))));
		assertTrue(((m3.addMoney(m4)).equals(new Money(1700, Currency.EURO))));
	}
	
	@Test
	public void testSub(){
		assertTrue(m1.subtMoney(m2).equals(new Money(600, Currency.EURO)));
		assertTrue(m2.subtMoney(m2).equals(new Money(0, Currency.EURO)));
		assertFalse(m3.subtMoney(m2).equals(new Money(600, Currency.EURO)));
	}
	
	@Test
	public void testCurrency(){
		assertTrue(m1.checkCurrency(Currency.EURO));
		assertFalse(m1.checkCurrency(Currency.DOLLAR));
		
	}
	
	@Test
	public void testGetVallue(){
		assertTrue(m1.getValue()== 1200);
		assertTrue(m2.getValue()== 600);
		assertTrue(m3.getValue()== 500);
		assertTrue(m4.getValue()== 1200);
		
	}
	
	
	@Test
	public void testChangeRate(){
		assertFalse(m1.getChangeRate()== 0.74f);
		assertTrue(m1.getChangeRate()== 1.44f);
	}
}
